/*
 * Filename:    HcpmsWarnServiceImpl.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年11月5日
 */
package com.paic.mhis.hcpms.warning.biz.service.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.paic.mhis.hcpms.agreement.healthcareprovider.util.HttpProcessUtil;
import com.paic.mhis.hcpms.audit.biz.service.ProblemNoticeService;
import com.paic.mhis.hcpms.common.document.biz.service.IDocumentService;
import com.paic.mhis.hcpms.common.document.dto.DocContentDTO;
import com.paic.mhis.hcpms.common.document.dto.DocParameterCondition;
import com.paic.mhis.hcpms.common.document.dto.DocSaveParamterDTO;
import com.paic.mhis.hcpms.common.storage.biz.service.HcpmsStorageService;
import com.paic.mhis.hcpms.common.storage.dto.HcpmsStorageDTO;
import com.paic.mhis.hcpms.common.workflow.vo.HcpmsWorkFlowVO;
import com.paic.mhis.hcpms.quota.settlement.dao.KpiDateDAO;
import com.paic.mhis.hcpms.trust.biz.service.IntegrityMedicalService;
import com.paic.mhis.hcpms.warning.biz.service.HcpmsWarnService;
import com.paic.mhis.hcpms.warning.biz.service.WarningWorkFlowService;
import com.paic.mhis.hcpms.warning.dto.HcpmsCodeListDTO;
import com.paic.mhis.hcpms.warning.dto.HcpmsWarnProcessInfoDTO;
import com.paic.mhis.hcpms.warning.dto.HcpmsWarnRalationDTO;
import com.paic.mhis.hcpms.warning.dto.HcpmsWarnScreenDTO;
import com.paic.mhis.hcpms.warning.dto.HcpmsWarnTargetDTO;
import com.paic.mhis.hcpms.warning.dto.HcpmsWarningDTO;
import com.paic.mhis.hcpms.warning.dto.HcpmsWarnsDTO;
import com.paic.mhis.hcpms.warning.dto.WarnResultDTO;
import com.paic.mhis.hcpms.warning.dto.WarnResultDetailDTO;
import com.paic.mhis.hcpms.warning.dto.WarningCheckDTO;
import com.paic.mhis.hcpms.warning.dto.WarningCheckDetailDTO;
import com.paic.mhis.hcpms.warning.dto.WarningMedicalDTO;
import com.paic.mhis.hcpms.warning.dto.WarningResultAuditDTO;
import com.paic.mhis.hcpms.warning.intergration.dao.HcpmsWarnDAO;
import com.paic.mhis.hcpms.warning.util.WarnConstants;
import com.paic.pafa.exceptions.BusinessException;

@Service("hcpmsWarnService")
public class HcpmsWarnServiceImpl implements HcpmsWarnService {

	@Autowired
	private HcpmsWarnDAO hcpmsWarnDao;
	@Autowired
	private IDocumentService iDocumentService;
	@Autowired
	private HcpmsStorageService hcpmsStorageService;
	@Autowired
	private KpiDateDAO kpiDateDao;
	@Autowired
	HcpmsStorageService storageService;
	@Autowired
	private WarningWorkFlowService warningWorkFlowService;
	@Autowired
	public ProblemNoticeService problemNoticeService;
	@Autowired
	private IntegrityMedicalService integrityMedicalService;

	@Override
	public Map<String, Object> getCodeList(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<HcpmsCodeListDTO> list = hcpmsWarnDao.getCodeList(map);
		result.put(WarnConstants.SUCCESS_RESULT_KEY, list);
		result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
		result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		return result;
	}

	private boolean getHcpmsWarnTarget(Map<String, Object> map) {
		String targetCode = hcpmsWarnDao.getgetHcpmsWarnTarget(map);
		if (!"".equals(targetCode) && targetCode != null) {
			return true;
		}
		return false;
	}

	public String getUUID() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}

	@Override
	public List<WarningCheckDetailDTO> getFeedBackDetailList(Map<String, Object> map) {
		return hcpmsWarnDao.getFeedBackDetailList(map);
	}

	@Override
	public Map<String, Object> getFeedBackList(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<WarningCheckDetailDTO> list = hcpmsWarnDao.getFeedBackDetailList(map);
		WarningCheckDTO warningCheckDTO = hcpmsWarnDao.getFeedBackList(map);
		result.put("checkResults", warningCheckDTO);
		// result.put("measure", warningCheckDTO.getCheckMeasure());
		// result.put("situation", warningCheckDTO.getCheckSituation());
		// result.put("sumamount", warningCheckDTO.getCheckSumamount());
		result.put("detailList", list);
		return result;
	}

	@Override
	public Map<String, Object> queryWarnData(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			HcpmsWarnsDTO dto = hcpmsWarnDao.getWarningInfo(map);
			result.put("warnInfo", getWarnInfo(dto, map));
			result.put("warnScreenList", getWarnScreenList(map));// hcpmsWarnDao.getWarnScreenList(map)
			List<WarningMedicalDTO> medical = hcpmsWarnDao.getWarnMedicalList(map);
			if (medical.size() > 0) {
				result.put("warnMedicalInfo", medical.get(0));
			}
			result.put("warnStaffList", getWarnStaffList(map));// hcpmsWarnDao.getWarnStaffList(map)
			result.put("warnInsuranceList", getWarnInsuranceList(map));// hcpmsWarnDao.getWarnInsuranceList(map)

			result.put(
					"notice",
					getWarnNotice(map.get("warnNo").toString(), WarnConstants.TASK_TYPE_WARNING,
							WarnConstants.DOC_TYPE_NOTICE, map.get("userId").toString()));
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_FAILED);
		}
		return result;
	}

	private Object getWarnScreenList(Map<String, Object> map) {
		HcpmsStorageDTO vo = new HcpmsStorageDTO();
		vo.setBusinessId(map.get("warnNo").toString());
		vo.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		vo.setUserId(map.get("userId").toString());
		vo.setBusinessType(WarnConstants.WARN_BUSINESS_SCREEN);
		Object obj = hcpmsStorageService.getStorageDataMap(vo);
		if (obj != null)
			return obj;
		return hcpmsWarnDao.getWarnScreenList(map);
	}

	private List<HcpmsWarnRalationDTO> getWarnInsuranceList(Map<String, Object> map) {
		HcpmsStorageDTO vo = new HcpmsStorageDTO();
		vo.setBusinessId(map.get("warnNo").toString());
		vo.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		vo.setUserId(map.get("userId").toString());
		vo.setBusinessType(WarnConstants.WARN_BUSINESS_INSUR);
		HcpmsStorageDTO dto = hcpmsStorageService.getStorageData(vo);
		if (dto != null && StringUtils.isNotBlank(dto.getUpdateCode())) {
			map.put("codeList", dto.getUpdateCode().split(","));
		} else if (dto != null && StringUtils.isBlank(dto.getUpdateCode())) {
			map.put("codeList", new String[] { "0000" });
		}
		return hcpmsWarnDao.getWarnInsuranceList(map);
	}

	private List<HcpmsWarnRalationDTO> getWarnStaffList(Map<String, Object> map) {
		HcpmsStorageDTO vo = new HcpmsStorageDTO();
		vo.setBusinessId(map.get("warnNo").toString());
		vo.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		vo.setUserId(map.get("userId").toString());
		vo.setBusinessType(WarnConstants.WARN_BUSINESS_STAFF);
		HcpmsStorageDTO dto = hcpmsStorageService.getStorageData(vo);
		if (dto != null && StringUtils.isNotBlank(dto.getUpdateCode())) {
			map.put("codeList", dto.getUpdateCode().split(","));
		} else if (dto != null && StringUtils.isBlank(dto.getUpdateCode())) {
			map.put("codeList", new String[] { "0000" });
		}
		return hcpmsWarnDao.getWarnStaffList(map);
	}

	public static void main(String[] args) {
		System.out.println(StringUtils.isBlank(null));
		System.out.println(StringUtils.isNotBlank("aaaa"));
	}

	private HcpmsWarnsDTO getWarnInfo(HcpmsWarnsDTO dto, Map<String, Object> map) {
		HcpmsStorageDTO vo = new HcpmsStorageDTO();
		vo.setBusinessId(map.get("warnNo").toString());
		vo.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		vo.setUserId(map.get("userId").toString());
		vo.setBusinessType(WarnConstants.WARN_BUSINESS_WARN);
		HcpmsWarnsDTO warnInfo = (HcpmsWarnsDTO) hcpmsStorageService.getStorageData(vo, dto);
		return warnInfo;
	}

	@Override
	public void updateHcpmsWarn(HcpmsWarningDTO warning) {
		hcpmsWarnDao.updateHcpmsWarn(warning);
	}

	public Map<String, Object> getDocData(List<DocContentDTO> list) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (list != null && list.size() > 0) {
			for (DocContentDTO dto : list) {
				map.put(dto.getDocKey(), dto.getDocValue1());
			}
		}
		return map;
	}

	@Override
	public Map<String, Object> saveWarnResultAudit(WarningResultAuditDTO dto) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			hcpmsWarnDao.saveWarnResultAudit(dto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_FAILED);
		}
		return result;
	}

	@Override
	public HcpmsWarnsDTO getWarnInfo(String warnNo) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("warnNo", warnNo);
		HcpmsWarnsDTO dto = hcpmsWarnDao.getWarningInfo(map);
		return dto;
	}

	@Override
	public Map<String, Object> getMedicalList(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<WarningMedicalDTO> ralationList = new ArrayList<WarningMedicalDTO>();
		try {
			int count = hcpmsWarnDao.getMedicalListCount(map);
			if (count > 0) {
				ralationList = hcpmsWarnDao.getMedicalList(map);
			}
			result.put(WarnConstants.SUCCESS_RESULT_KEY, ralationList);
			result.put(WarnConstants.TOTAL, count);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> getStaffList(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			List<HcpmsWarnRalationDTO> ralationList = hcpmsWarnDao.getStaffList(map);
			result.put(WarnConstants.SUCCESS_RESULT_KEY, ralationList);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> getInsuranceList(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<HcpmsWarnRalationDTO> ralationList = new ArrayList<HcpmsWarnRalationDTO>();
		try {
			int count = hcpmsWarnDao.getInsuranceListCount(map);
			if (count > 0) {
				ralationList = hcpmsWarnDao.getInsuranceList(map);
			}
			result.put(WarnConstants.SUCCESS_RESULT_KEY, ralationList);
			result.put(WarnConstants.TOTAL, count);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_FAILED);
		}
		return result;
	}

	@Override
	public void warningChangeAudit(String warnNo) {
		hcpmsWarnDao.warningChangeAudit(warnNo);
	}

	@Override
	public Map<String, Object> editHcpmsWarn(JSONObject json, String userId, String warnNo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		HcpmsWarnsDTO warns = JSONObject.toJavaObject(json, HcpmsWarnsDTO.class);
		HcpmsWarningDTO dto = warns.getHcpmsWarning();
		String checkWarnNo = hcpmsWarnDao.checkWarnNoBiz(dto.getWarnNoBiz());
		if (null != checkWarnNo && !"".equals(checkWarnNo)) {
			if (!"".equals(dto.getWarnNo()) && dto.getWarnNo() != null && dto.getWarnNo().equals(checkWarnNo)) {

			} else {
				return result;
			}
		}
		String isCheckBack = json.getString("isCheckBack");
		if (isCheckBack != null && !isCheckBack.equals("")) {
			dto.setIsCheckBack(isCheckBack);
		}
		if ("".equals(userId) || userId == null) {
			userId = "hcpmsdata";
		}
		if (!"".equals(dto.getWarnNo()) && dto.getWarnNo() != null) {
			dto.setUpdatedBy(userId);
			if (WarnConstants.WARN_STATUS_4.equals(dto.getStatus())) {
				dto.setAuditor(userId);
				dto.setAuditDate(new Date());
			} else if (WarnConstants.WARN_STATUS_8.equals(dto.getStatus())) {
				dto.setApprover(userId);
				dto.setApproveDate(new Date());
			} else if (WarnConstants.WARN_STATUS_1.equals(dto.getStatus())) {
				dto.setAgent(userId);
				dto.setAgentDate(new Date());
			}
			hcpmsWarnDao.updateHcpmsWarn(dto);
			result.put(WarnConstants.RESULT_BUSINESS_WARN_KEY, dto.getWarnNo());
		} else {
			warnNo = hcpmsWarnDao.createWarnNo(WarnConstants.BUSINESS_WARING);
			dto.setWarnNo(warnNo);
			dto.setAgent(userId);
			dto.setUpdatedBy(userId);
			dto.setIsValid(WarnConstants.IS_VALID_0);
			hcpmsWarnDao.createHcpmsWarn(dto);
			result.put(WarnConstants.RESULT_BUSINESS_WARN_KEY, warnNo);
		}
		// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
		// storageDto.setBusinessId(warnNo);
		// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		// storageDto.setUserId(userId);
		// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_WARN);
		// hcpmsStorageService.deleteStorageData(storageDto);
		result.put("warnInfo", dto);
		result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
		result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		return result;
	}

	@Override
	public Map<String, Object> editHcpmsWarnTarget(JSONObject json, String userId, String warnNo, String type) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null || json.equals(new JSONObject())) {
			return result;
		}
		try {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("warnNo", warnNo);
			map.put("isValid", WarnConstants.IS_VALID_0);
			List<String> idList = new ArrayList<String>();
			WarningMedicalDTO dto = JSONObject.toJavaObject(json, WarningMedicalDTO.class);
			map.put("targetType", type);
			map.put("targetCode", dto.getCode());
			if (!getHcpmsWarnTarget(map)) {
				HcpmsWarnTargetDTO target = new HcpmsWarnTargetDTO();
				target.setTargetCode(dto.getCode());
				target.setTargetName(dto.getName());
				target.setTargetType(type);
				target.setWarnNo(warnNo);
				target.setIsValid(WarnConstants.IS_VALID_0);
				hcpmsWarnDao.createHcpmsWarnTarget(target);
				idList.add(dto.getCode());
				map.put("targetCode", idList);
				map.put("isValid", WarnConstants.IS_VALID_1);
				hcpmsWarnDao.updateHcpmsWarnTarget(map);
			}
			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setUserId(userId);
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_MEDICAL);
			// hcpmsStorageService.deleteStorageData(storageDto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> editHcpmsWarnTarget(JSONArray json, String userId, String warnNo, String type) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		if (json.size() <= 0) {
			Map<String, Object> map = new HashMap<String, Object>();
			List<String> idList = new ArrayList<String>();
			map.put("warnNo", warnNo);
			map.put("targetCode", idList);
			map.put("targetType", type);
			map.put("isValid", WarnConstants.IS_VALID_1);
			hcpmsWarnDao.updateHcpmsWarnTarget(map);
			return result;
		}
		try {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("warnNo", warnNo);
			map.put("targetType", type);
			map.put("isValid", WarnConstants.IS_VALID_0);
			List<String> idList = new ArrayList<String>();
			for (int i = 0; i < json.size(); i++) {
				HcpmsWarnRalationDTO dto = JSONObject.toJavaObject(json.getJSONObject(i), HcpmsWarnRalationDTO.class);
				map.put("targetCode", dto.getCode());
				idList.add(dto.getCode());
				if (!getHcpmsWarnTarget(map)) {
					HcpmsWarnTargetDTO target = new HcpmsWarnTargetDTO();
					target.setTargetCode(dto.getCode());
					target.setTargetName(dto.getName());
					target.setTargetType(type);
					target.setWarnNo(warnNo);
					target.setIsValid(WarnConstants.IS_VALID_0);
					hcpmsWarnDao.createHcpmsWarnTarget(target);
				}
			}
			map.put("targetCode", idList);
			map.put("isValid", WarnConstants.IS_VALID_1);
			hcpmsWarnDao.updateHcpmsWarnTarget(map);
			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setUserId(userId);
			// if (WarnConstants.TARGET_TYPE_STAFF.equals(type)) {
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_STAFF);
			// } else if (WarnConstants.TARGET_TYPE_INSURANCE.equals(type)) {
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_INSUR);
			// }
			// hcpmsStorageService.deleteStorageData(storageDto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> editHcpmsWarnScreen(JSONArray json, String userId, String warnNo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		if (json.size() <= 0) {
			Map<String, Object> map = new HashMap<String, Object>();
			List<String> list = new ArrayList<String>();
			map.put("warnNo", warnNo);
			map.put("screenIds", list);
			map.put("userId", userId);
			map.put("isValid", WarnConstants.IS_VALID_1);
			hcpmsWarnDao.updateHcpmsWarnScreen(map);
			return result;
		}
		try {
			List<String> list = new ArrayList<String>();
			for (int i = 0; i < json.size(); i++) {
				HcpmsWarnScreenDTO dto = JSONObject.toJavaObject(json.getJSONObject(i), HcpmsWarnScreenDTO.class);
				if (!"".equals(dto.getWarnNo()) && dto.getWarnNo() != null) {
					list.add(dto.getIdScreen());
				} else {
					dto.setIdScreen(getUUID());
					list.add(dto.getIdScreen());
					dto.setWarnNo(warnNo);
					dto.setCreatedBy(userId);
					dto.setUpdatedBy(userId);
					dto.setIsValid(WarnConstants.IS_VALID_0);
					hcpmsWarnDao.createHcpmsWarnScreen(dto);
				}
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("warnNo", warnNo);
			map.put("screenIds", list);
			map.put("userId", userId);
			map.put("isValid", WarnConstants.IS_VALID_1);
			hcpmsWarnDao.updateHcpmsWarnScreen(map);
			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setUserId(userId);
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_SCREEN);
			// hcpmsStorageService.deleteStorageData(storageDto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> editHcpmsWarnNotice(JSONObject json, String userId, String warnNo, String taskType,
			String docTyp) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		try {
			DocParameterCondition param = new DocParameterCondition();
			param.setTaskNo(warnNo);
			param.setTaskType(taskType);
			param.setDocType(docTyp);

			DocSaveParamterDTO docDto = new DocSaveParamterDTO();
			docDto.setTaskNo(warnNo);
			docDto.setTaskType(taskType);
			docDto.setDocType(docTyp);

			docDto.setMap(json);

			docDto.setCreateUser(userId);
			iDocumentService.saveDocumentContent(docDto);

			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setUserId(userId);
			// if (WarnConstants.DOC_TYPE_NOTICE.equals(docTyp)) {
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_NOTICE);
			// } else {
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_RESULT_TOLD);
			// }
			// hcpmsStorageService.deleteStorageData(storageDto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> editAssessResultList(JSONArray json, String userId, String warnNo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		if (json.size() <= 0) {
			Map<String, Object> map = new HashMap<String, Object>();
			List<String> list = new ArrayList<String>();
			map.put("warnNo", warnNo);
			map.put("idList", list);
			hcpmsWarnDao.updateAssessResultDetail(map);
			return result;
		}
		try {
			List<String> list = new ArrayList<String>();
			for (int i = 0; i < json.size(); i++) {
				WarnResultDetailDTO dto = JSONObject.toJavaObject(json.getJSONObject(i), WarnResultDetailDTO.class);
				if (!"".equals(dto.getIdWarnFeeback()) && dto.getIdWarnFeeback() != null) {
				} else {
					dto.setIdWarnFeeback(getUUID());
					dto.setWarnNo(warnNo);
					hcpmsWarnDao.saveAssessResultDetail(dto);
				}
				list.add(dto.getIdWarnFeeback());
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("warnNo", warnNo);
				map.put("idList", list);
				hcpmsWarnDao.updateAssessResultDetail(map);
			}
			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setUserId(userId);
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_ASSESS_LIST);
			// hcpmsStorageService.deleteStorageData(storageDto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> editAssessResult(JSONObject json, String username, String warnNo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		try {
			SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
			WarnResultDTO dto = JSONObject.toJavaObject(json, WarnResultDTO.class);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("warnNo", warnNo);
			WarnResultDTO reDto = hcpmsWarnDao.getWarnResult(map);
			dto.setUpdatedBy(username);
			dto.setAgent(username);
			if (!"".equals(dto.getTraceStartDate()) && dto.getTraceStartDate() != null) {
				dto.setStartDate(sft.parse(dto.getTraceStartDate()));
			}
			if (!"".equals(dto.getTraceEndDate()) && dto.getTraceEndDate() != null) {
				dto.setEndDate(sft.parse(dto.getTraceEndDate()));
			}
			if (reDto != null) {
				hcpmsWarnDao.updateAssessResult(dto);
			} else {
				dto.setWarnNo(warnNo);
				hcpmsWarnDao.saveAssessResult(dto);
			}
			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_ASSESS);
			// storageDto.setUserId(username);
			// hcpmsStorageService.deleteStorageData(storageDto);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
		result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);

		return result;
	}

	@Override
	public Map<String, Object> editWarnResultAudit(JSONObject json, String username, String warnNo) {
		Map<String, Object> result = new HashMap<String, Object>();
		if (json == null) {
			return result;
		}
		try {
			WarningResultAuditDTO dto = JSONObject.toJavaObject(json, WarningResultAuditDTO.class);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("warnNo", warnNo);
			WarningResultAuditDTO reDto = hcpmsWarnDao.getAuditResult(map);
			dto.setAuditor(username);
			if (reDto != null) {
				hcpmsWarnDao.updateWarnResultAudit(dto);
			} else {
				dto.setWarnNo(warnNo);
				hcpmsWarnDao.saveWarnResultAudit(dto);
			}
			// HcpmsStorageDTO storageDto = new HcpmsStorageDTO();
			// storageDto.setBusinessId(warnNo);
			// storageDto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			// storageDto.setBusinessType(WarnConstants.WARN_BUSINESS_RESULT);
			// storageDto.setUserId(username);
			// hcpmsStorageService.deleteStorageData(storageDto);
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_SUCCESS);
		} catch (Exception e) {
			result.put(WarnConstants.STATE_KEY, WarnConstants.FAILED_STATE_VALUE);
			result.put(WarnConstants.MSG_KEY, WarnConstants.SAVE_FAILED);
		}
		return result;
	}

	@Override
	public Map<String, Object> getWarnResult(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			HcpmsStorageDTO dto = new HcpmsStorageDTO();
			dto.setBusinessId(map.get("warnNo").toString());
			dto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			dto.setUserId(map.get("userId").toString());
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_ASSESS);
			Object obj = hcpmsStorageService.getStorageDataMap(dto);
			if (obj != null) {
				result.put("warnResult", obj);
			} else {
				result.put("warnResult", hcpmsWarnDao.getWarnResult(map));
			}
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_ASSESS_LIST);
			Object obj1 = hcpmsStorageService.getStorageDataMap(dto);
			if (obj1 != null) {
				result.put("warnResultList", obj1);
			} else {
				result.put("warnResultList", hcpmsWarnDao.getWarnResultList(map));
			}
		} catch (Exception e) {

		}
		return result;
	}

	@Override
	public Map<String, Object> getAuditResult(Map<String, Object> map) {
		Map<String, Object> result = new HashMap<String, Object>();
		try {
			HcpmsStorageDTO dto = new HcpmsStorageDTO();
			dto.setBusinessId(map.get("warnNo").toString());
			dto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			dto.setUserId(map.get("userId").toString());
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_RESULT);
			Object obj = hcpmsStorageService.getStorageDataMap(dto);
			if (obj != null) {
				result.put("auditResult", obj);
			} else {
				result.put("auditResult", hcpmsWarnDao.getAuditResult(map));
			}
		} catch (Exception e) {
		}
		return result;
	}

	@Override
	public Map<String, Object> getWarnNotice(String warnNo, String taskType, String docType, String userId) {
		HcpmsStorageDTO dto = new HcpmsStorageDTO();
		dto.setBusinessId(warnNo);
		dto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		dto.setUserId(userId);
		if (WarnConstants.DOC_TYPE_NOTICE.equals(docType)) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_NOTICE);
		} else if (WarnConstants.DOC_TYPE_TOLD.equals(docType)) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_RESULT_TOLD);
		}
		Object obj = hcpmsStorageService.getStorageDataMap(dto);
		if (obj != null) {
			return (Map<String, Object>) (JSONObject) obj;
		}
		DocParameterCondition param = new DocParameterCondition();
		param.setTaskNo(warnNo);
		param.setTaskType(taskType);
		param.setDocType(docType);
		Map<String, Object> result = getDocData(iDocumentService.queryByDocParameterCondition(param));
		return result;
	}

	@Override
	public Map<String, Object> getBaseFormParam(List<String> codeType) {
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("codeTypes", codeType);
		List<HcpmsCodeListDTO> list = hcpmsWarnDao.getCodeList(map);
		for (int i = 0; i < codeType.size(); i++) {
			result.put(codeType.get(i), getCodeTypeList(list, codeType.get(i)));
		}
		result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
		result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		return result;
	}

	private Object getCodeTypeList(List<HcpmsCodeListDTO> list, String codeType) {
		List<HcpmsCodeListDTO> resultList = new ArrayList<HcpmsCodeListDTO>();
		if (list.size() <= 0) {
			return resultList;
		}
		for (int i = 0; i < list.size(); i++) {
			HcpmsCodeListDTO dto = list.get(i);
			if (codeType.equals(dto.getCodeType())) {
				resultList.add(dto);
			}
		}
		return resultList;
	}

	/**
	 * 预警通知单号
	 */
	@Override
	public String createWarnNoticeNum(Map<String, Object> map) {
		return hcpmsWarnDao.createWarnNoticeNum();
	}

	/***
	 * 根据不同的类型暂存不同表的数据
	 */
	@Override
	public Map<String, Object> editStorageSave(JSONObject transferJson, String warnNo, String userId) {
		Map<String, Object> result = new HashMap<String, Object>();
		HcpmsStorageDTO dto = new HcpmsStorageDTO();
		dto.setBusinessId(warnNo);
		dto.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		dto.setUserId(userId);
		if (transferJson.get("warnInfo") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_WARN);
			dto.setDataMap(transferJson.get("warnInfo"));
			hcpmsStorageService.saveStorageData(dto, true);
		}
		if (transferJson.get("staffList") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_STAFF);
			dto.setDataMap(transferJson.get("staffList"));
			dto.setUpdateCode(getListParamValue(transferJson.getJSONArray("staffList"), "code"));
			hcpmsStorageService.saveStorageData(dto, false);
		}
		if (transferJson.get("insurList") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_INSUR);
			dto.setDataMap(transferJson.get("insurList"));
			dto.setUpdateCode(getListParamValue(transferJson.getJSONArray("insurList"), "code"));
			hcpmsStorageService.saveStorageData(dto, false);
		}
		if (transferJson.get("screenList") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_SCREEN);
			dto.setDataMap(transferJson.get("screenList"));
			hcpmsStorageService.saveStorageData(dto, false);
		}
		if (transferJson.get("assessResultList") != null
		// && !transferJson.get("assessResultList").equals(new JSONObject())
		// && !transferJson.get("assessResultList").equals(new JSONArray())
		) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_ASSESS_LIST);
			dto.setDataMap(transferJson.get("assessResultList"));
			hcpmsStorageService.saveStorageData(dto, false);
		}
		if (transferJson.get("assessResult") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_ASSESS);
			dto.setDataMap(transferJson.get("assessResult"));
			hcpmsStorageService.saveStorageData(dto, false);
		}
		if (transferJson.get("auditResult") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_RESULT);
			dto.setDataMap(transferJson.remove("auditResult"));
			hcpmsStorageService.saveStorageData(dto, false);
		}
		if (transferJson.get("resultNotice") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_RESULT_TOLD);
			dto.setDataMap(transferJson.get("resultNotice"));
			hcpmsStorageService.saveStorageData(dto, true);
		}
		if (transferJson.get("warnMarkTempDetails") != null) {
			dto.setBusinessType(WarnConstants.WARN_BUSINESS_POINT);
			dto.setDataMap(transferJson);
			hcpmsStorageService.saveStorageData(dto, true);
		}
		result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
		result.put(WarnConstants.MSG_KEY, WarnConstants.SELECT_SUCCESS);
		return result;
	}

	private String getListParamValue(JSONArray json, String key) {
		StringBuffer buff = new StringBuffer();
		if (json.equals(new JSONArray())) {
			return "";
		}
		for (int i = 0; i < json.size(); i++) {
			JSONObject js = json.getJSONObject(i);
			buff.append(js.get(key)).append(",");
		}
		return buff.toString().substring(0, buff.length() - 1);
	}

	@Override
	public void deleteStorageDateAll(String warnNo, String userId) {
		HcpmsStorageDTO vo = new HcpmsStorageDTO();
		vo.setBusinessId(warnNo);
		vo.setModuleType(WarnConstants.WARN_MODULE_TYPE);
		if (StringUtils.isNotBlank(userId)) {
			vo.setUserId(userId);
		}
		hcpmsStorageService.deleteStorageData(vo);
	}

	@Override
	public void deleteUpNodeDate(String warnNo, String businessType) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("warnNo", warnNo);
		map.put("businessType", businessType);
		hcpmsWarnDao.deleteUpNodeDate(map);
	}

	/**
	 * 获取暂存数据
	 * 
	 * @param storageList
	 * @return
	 */
	public Map<String, Object> getAuditStorage(List<HcpmsStorageDTO> storageList) {
		Map<String, Object> result = new HashMap<String, Object>();
		for (HcpmsStorageDTO dto : storageList) {
			if (dto.getBusinessType().equals(WarnConstants.WARN_BUSINESS_STAFF)) {// 医护人员
				result.put(WarnConstants.WARN_BUSINESS_STAFF, dto.getDataMap());
			}
			if (dto.getBusinessType().equals(WarnConstants.WARN_BUSINESS_SCREEN)) {// 网上筛查
				result.put(WarnConstants.WARN_BUSINESS_SCREEN, dto.getDataMap());
			}
			if (dto.getBusinessType().equals(WarnConstants.WARN_BUSINESS_WARN)) {// 主对象(包括初审和审批)
				result.put(WarnConstants.WARN_BUSINESS_WARN, dto.getDataMap());
			}
			if (dto.getBusinessType().equals(WarnConstants.WARN_BUSINESS_POINT)) {// 扣分的业务类型
				result.put(WarnConstants.WARN_BUSINESS_POINT, dto.getDataMap());
			}
			if (dto.getBusinessType().equals(WarnConstants.WARN_BUSINESS_INSUR)) {// 参保人
				result.put(WarnConstants.WARN_BUSINESS_INSUR, dto.getDataMap());
			}
			if (dto.getBusinessType().equals(WarnConstants.WARN_BUSINESS_ASSESS_LIST)) {// 结论评估左
				result.put(WarnConstants.WARN_BUSINESS_ASSESS_LIST, dto.getDataMap());
			}
		}
		return result;
	}

	/**
	 * 批量审核
	 */
	@Override
	public Map<String, Object> auditWarnBatch(JSONObject json, String userName) {
		String auditOpinion = json.getString("auditOpinion");
		String auditDesc = json.getString("auditDesc");
		Map<String, Object> result = new HashMap<String, Object>();
		JSONArray auditBatchArray = json.getJSONArray("batchWarnList");
		Map<String, Object> warnData = new HashMap<String, Object>();
		Map<String, Object> paramMap = new HashMap<String, Object>();
		Map<String, Object> storageMap = new HashMap<String, Object>();

		String warnNo = "";
		String status = "";
		String process = "";

		int notPowerError = 0;// 处理的节点已经变更
		int outPowerError = 0;// 同组其他人员已经对其进行操作
		int systemError = 0;// 系统数据库错误
		int batchSize = auditBatchArray.size();
		for (int i = 0; i < batchSize; i++) {
			HcpmsWarnsDTO dto = JSONObject.toJavaObject(auditBatchArray.getJSONObject(i), HcpmsWarnsDTO.class);
			HcpmsStorageDTO vo = new HcpmsStorageDTO();
			vo.setModuleType(WarnConstants.WARN_MODULE_TYPE);
			vo.setBusinessId(dto.getWarnNo());
			vo.setUserId(userName);
			List<HcpmsStorageDTO> storageList = storageService.getStorageDataList(vo);
			JSONObject warnInfo = new JSONObject();
			paramMap.put("warnNo", dto.getWarnNo());
			paramMap.put("userId", userName);
			warnData = queryWarnData(paramMap);
			HcpmsWarnsDTO warnsDTO = (HcpmsWarnsDTO) warnData.get("warnInfo");
			warnNo = warnsDTO.getWarnNo();
			status = warnsDTO.getStatus();
			String feedBackEndDate = "";
			if (storageList != null && storageList.size() > 0) {// 有暂存数据
				storageMap = getAuditStorage(storageList);
				if (storageMap.containsKey(WarnConstants.WARN_BUSINESS_WARN)) {
					warnInfo = (JSONObject) storageMap.get(WarnConstants.WARN_BUSINESS_WARN);
				}
				process = warnsDTO.getProcess();// 02时需要设置feedbackEndDate
				if (warnInfo.containsKey("feedbackEndDate") && !warnInfo.getString("feedbackEndDate").equals("")) {
					feedBackEndDate = warnInfo.getString("feedbackEndDate");
				}
				warnInfo.put("warnNo", warnNo);
				warnInfo.put("status", status);
			} else {// 未找到暂存数据
				warnInfo = (JSONObject) JSONObject.toJSON(warnData.get("warnInfo"));
				process = warnInfo.getString("process");// 处理方式为自查整改(02),审核同意时需要设置反馈截止日期(feedbackEndDate)
			}
			if (auditOpinion != null && auditOpinion.equals("01") && (process.equals("02") || process.equals("04"))) {
				warnInfo.put("feedbackEndDate", feedBackEndDate.equals("") ? getFeedBackEndDate() : feedBackEndDate);
			}
			warnInfo.put("auditDesc", auditDesc);
			warnInfo.put("auditOpinion", auditOpinion);
			if (auditOpinion != null && auditOpinion.equals("02")) {
				warnInfo.put("isCheckBack", "1");
			} else {
				warnInfo.put("isCheckBack", "0");
			}
			// -----------------
			if (!"".equals(warnNo) && warnNo != null && !"".equals(status) && status != null) {
				String processState = warningWorkFlowService.vilidateOrBindUser(warnNo, userName, status);
				if (WarnConstants.PROCESS_NOT_POWER.endsWith(processState)) {
					notPowerError += 1;
					continue;
				} else if (WarnConstants.PROCESS_OUT_POWER.endsWith(processState)) {
					outPowerError += 1;
					continue;
				}
			}
			HcpmsWarningDTO warning = null;
			try {
				warning = (HcpmsWarningDTO) editHcpmsWarn(warnInfo, userName, warnNo).get("warnInfo");
			} catch (Exception e) {
				systemError += 1;
				HttpProcessUtil.processException(e);
			}
			// 批量记分调用方法：
			Map<String, Object> pointParamMap = new HashMap<String, Object>();
			pointParamMap.put("caseType", "01");// 01:预警，02：稽核
			pointParamMap.put("caseNo", warnNo);// 案件号
			pointParamMap.put("userName", userName);// 当前操作人
			try {
				integrityMedicalService.batchAddPointCutTemps(pointParamMap);
			} catch (BusinessException e1) {
				e1.printStackTrace();
			}
			if (storageList.size() > 0) {
				if (storageMap.containsKey(WarnConstants.WARN_BUSINESS_STAFF)) {// 医护人员
					editHcpmsWarnTarget((JSONArray) storageMap.get(WarnConstants.WARN_BUSINESS_STAFF), userName,
							warnNo, WarnConstants.TARGET_TYPE_STAFF);
				}
				if (storageMap.containsKey(WarnConstants.WARN_BUSINESS_INSUR)) {// 参保人员
					editHcpmsWarnTarget((JSONArray) storageMap.get(WarnConstants.WARN_BUSINESS_INSUR), userName,
							warnNo, WarnConstants.TARGET_TYPE_INSURANCE);
				}
				if (storageMap.containsKey(WarnConstants.WARN_BUSINESS_SCREEN)) {// 网上筛查
					editHcpmsWarnScreen((JSONArray) storageMap.get(WarnConstants.WARN_BUSINESS_SCREEN), userName,
							warnNo);
				}
				if (storageMap.containsKey(WarnConstants.WARN_BUSINESS_NOTICE)) {// 通知单
					editHcpmsWarnNotice((JSONObject) storageMap.get(WarnConstants.WARN_BUSINESS_NOTICE), userName,
							warnNo, WarnConstants.TASK_TYPE_WARNING, WarnConstants.DOC_TYPE_NOTICE);
				}
			}
			try {
				HcpmsWarningDTO warnDto = new HcpmsWarningDTO();
				HcpmsWorkFlowVO wfvo = new HcpmsWorkFlowVO();
				wfvo.setTaskNo(warnNo);
				wfvo.setActCurrent(userName);
				Map<String, String> condition = new HashMap<String, String>();
				if (WarnConstants.WARN_PROCESS_BACK.equals(warning.getAuditOpinion())) {
					wfvo.setAssigner(warning.getAgent());
					condition.put("AUDIT_OPINION", warning.getAuditOpinion());
				} else {
					if (WarnConstants.WARN_PROCESS_TYPE_03.equals(warning.getProcess())
							|| WarnConstants.WARN_PROCESS_TYPE_05.equals(warning.getProcess())) {
						condition.put("PROCESS_TYPE", warning.getProcess());
					} else {
						condition.put("AUDIT_OPINION", warning.getAuditOpinion());
						warnDto.setIsFeedback(WarnConstants.WARN_ISFEEDBACK_01);
					}
				}
				wfvo.setParamValue(condition);
				String actCurrent = warningWorkFlowService.processWorkFlow(wfvo);
				// 更新状态
				warnDto.setWarnNo(warnNo);
				warnDto.setUpdatedBy(userName);
				warnDto.setStatus(actCurrent);
				updateHcpmsWarn(warnDto);
				deleteStorageDateAll(warnNo, null);
				if ("N2014009".equals(actCurrent) && WarnConstants.WARN_PROCESS_TYPE_03.equals(warning.getProcess())) {
					warningChangeAudit(warnNo);
					problemNoticeService.notice();
				}
			} catch (Exception e) {
				systemError += 1;
				result = HttpProcessUtil.processException(e);
			}
			result.put(WarnConstants.STATE_KEY, WarnConstants.SUCCESS_STATE_VALUE);
			result.put(WarnConstants.WARN_BATCH_COUNT_SUCCESS, batchSize - notPowerError - outPowerError - systemError);
			result.put(WarnConstants.WARN_BATCH_COUNT_FAILED, notPowerError + outPowerError + systemError);
			// ---------------
		}
		batchMessageProcess(result);
		return result;
	}

	void batchMessageProcess(Map<String, Object> result) {
		String stateKey = result.get(WarnConstants.STATE_KEY).toString();
		if (stateKey.equals("0")) {
			result.put(WarnConstants.MSG_KEY, "操作成功,其中成功" + result.get(WarnConstants.WARN_BATCH_COUNT_SUCCESS) + "条,失败"
					+ result.get(WarnConstants.WARN_BATCH_COUNT_FAILED) + "条!");
		} else {
			result.put(WarnConstants.MSG_KEY, "已选中的数据第" + result.get(WarnConstants.MSG_KEY).toString() + "行验证不通过!");
		}
	}

	/**
	 * 反馈截止日期
	 * 
	 * @return
	 */
	public String getFeedBackEndDate() {
		String today = kpiDateDao.getKpiSysDate("yyyy-MM-dd");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar ca = Calendar.getInstance();
		try {
			ca.setTime(sdf.parse(today));
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
		ca.add(Calendar.DAY_OF_YEAR, 5);
		return sdf.format(ca.getTime());
	}
	
	/**
	 * 流程信息查看
	 * @param map
	 * @return
	 */
	@Override
	public List<HcpmsWarnProcessInfoDTO> getAllWorkFlowInfo(
			Map<String, Object> map) {
		List<HcpmsWarnProcessInfoDTO> dataList=new ArrayList<HcpmsWarnProcessInfoDTO>();
		dataList=hcpmsWarnDao.getAllWorkFlowInfo(map);
		for(HcpmsWarnProcessInfoDTO dto:dataList){
			if(dto.getStatus().length()>3&&dto.getActcurrent().compareTo(dto.getStatus())>=0){
				dto.setuName("");
				dto.setuDate("");
			}
			if((dto.getStatus().equals("N2014003")&&dto.getActcurrent().equals("N2014002"))){
				dto.setuDate(dto.getUpdatedate());
			}
		}
		return dataList;
	}
	/**
	 * 流程状态信息
	 * @param map
	 * @return
	 */
	@Override
	public String queryProcessStatusInfo(Map<String, Object> map) {
		return hcpmsWarnDao.queryProcessStatusInfo(map);
	}


}
